\<%@ page import="com.surelution.projects.crm.CardAssign" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="layout" content="main"/>
<g:set var="entityName" value="${message(code: 'cardAssign.label', default: 'cardAssign')}" />
<g:javascript library="jquery"/>
<resource:dateChooser />
<link rel="stylesheet" href="${resource(dir:'css',file:'defaultTheme.css')}" />
<script type="text/javascript" src="${resource(dir:'js/jquery',file:'jquery.fixedheadertable.min.js')}"></script>
<script type="text/javascript" src="${resource(dir:'js/jquery',file:'jquery.printElement.min.js')}"></script>
<script type="text/javascript" src="${resource(dir:'js/datechooser',file:'datechooser.js')}"></script>
<title><g:message code="default.depositMoney.label" /></title>
	<script type="text/javascript">
		$(document).ready(function() {
		   $("#simplePrint").click(function() {
		       printElem({leaveOpen: true, printMode: 'popup', overrideElementCSS: ["${resource(dir:'plugins/richui-0.8/css',file:'calendarmonthview.css')}","${resource(dir:'css',file:'main.css')}"]});
		   });
		   $('#myTable01').fixedHeaderTable({ footer: false, cloneHeadToFoot: false, autoShow: true });
		});
		function printElem(options){
		    $('#cardPropReport').printElement(options);
		};
	</script>
</head>

<body>
  <div class="body">
          <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="create" action="compareDeposit"><g:message code="default.compareDespoit.label" /></g:link></span>
          </div>
          <div>
			<p style="font-size:16px;color:#000;margin:10px 0;">沉淀资金查询</p>
        	<g:form action="depositMoney">
        		选择日期：<richui:dateChooser locale="zh" name="startDay" format="yyyy-MM-dd" value="${startDay}"/>至<richui:dateChooser name="endDay" locale="zh" format="yyyy-MM-dd" value="${endDay}"/>
    			<g:submitButton name="查询" style="margin-right:5px;"/><input type="button" value="打印报表" id="simplePrint" />
			    <span class="menuButton"><g:actionSubmit value="${message(code: 'default.button.export.label', default: 'Export')}" action="exportDespoit"/></span>
			</g:form>
			<g:if test="${flash.message}">
            	<div class="message">${flash.message}</div>
            </g:if>
        </div>
        <%
			def tRechange=0,tConsume=0,tDeposit=0
		 %>
        <div id="cardPropReport" style="height:630px;">
   			<p style="font-size:16px;color:#000;margin:10px 0;">报表日期: ${startDay.format("yyyy.MM.dd")}-${endDay.format("yyyy.MM.dd")}</p>
       		<table id="myTable01">
       			<thead>
        		<tr>
        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;width:150px;">加油站名</td>
        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;width:150px;">总消费量</td>
        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;width:150px;">总充值量</td>
        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;width:150px;">沉淀资金量(充值-消费)</td>
        			<td style="text-align: center;vertical-align: middle;background:#75746a;color:#fff;width:150px;">排名</td>
        		</tr>
        		<tr class="even">
   					<td style="text-align:center;">合计</td>
					<td style="text-align:center;"><div id="tRechange"></div></td>
					<td style="text-align:center;"><div id="tConsume"></div></td>
					<td style="text-align:center;"><div id="tDeposit"></div></td>
					<td style="text-align:center;">0</td>
   				</tr>
   				</thead>
   				<tbody>
				<g:each in="${cardPropList}" var="crList" status="i">
				<%
					tRechange += crList[1]
				   	tConsume += crList[2]
				   	tDeposit += crList[3]
				 %>
					<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
   						<td>${crList[0].shortName}</td>
						<td style="text-align:center"><g:formatNumber number="${crList[1]}" type="number" maxFractionDigits="2" /></td>
						<td style="text-align:center"><g:formatNumber number="${crList[2]}" type="number" maxFractionDigits="2" /></td>
						<td style="text-align:center"><g:formatNumber number="${crList[3]}" type="number" maxFractionDigits="2" /></td>
						<td style="text-align:center">${i+1}</td>
					</tr>
				</g:each>
				</tbody>
          	</table>
        </div>
		<script type="text/javascript">
			document.getElementById("tRechange").innerHTML = '${(formatNumber(number:tRechange,maxFractionDigits:2)) }';
			document.getElementById("tConsume").innerHTML = '${(formatNumber(number:tConsume,maxFractionDigits:2)) }';
			document.getElementById("tDeposit").innerHTML = '${(formatNumber(number:tDeposit,maxFractionDigits:2)) }';
        </script>
  </div>
</body>
</html>